#pragma once

#include "MvCamera.h"
#include "afxcmn.h"
#include "afxwin.h"

// CForceIpDlg 对话框
// CForceIpDlg dialog
class CForceIpDlg : public CDialog
{
	DECLARE_DYNAMIC(CForceIpDlg)

public:
	CForceIpDlg(CWnd* pParent = NULL);   // 标准构造函数 |construct function
	virtual ~CForceIpDlg();

// 对话框数据 | dialog data
	enum { IDD = IDD_DIALOG_FORCEIP };

public:
	void setMvCamera(const Dahua::CMvCameraPtr& sptrMvCamera);

protected:
	virtual BOOL OnInitDialog();
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持 | DDX/DDV support

	DECLARE_MESSAGE_MAP()

private:
	void initNetAddressInfo();
	void strIpToNumberIp(const char* pIp, int* pszIp, int iSize);

private:
	Dahua::CMvCameraPtr				m_sptrMvCamera;
public:
	afx_msg void OnBnClickedOk();
	CIPAddressCtrl m_ipctrlInterfaceGateway;
	CIPAddressCtrl m_ipctrlInterfaceMask;
	CIPAddressCtrl m_ipctrlInterfaceIp;
	CIPAddressCtrl m_ipctrlCameraGateway;
	CIPAddressCtrl m_ipctrlCameraMask;
	CIPAddressCtrl m_ipctrlCameraIp;
	CEdit m_editInterfaceMac;
	CEdit m_editCameraMac;
};

static std::wstring StringToWString(const std::string& str)
{
	std::wstring wstr(str.length(), L' ');

	//std::copy(str.begin(), str.end(), wstr.begin());
	MultiByteToWideChar(CP_ACP, 0, (LPCSTR)str.c_str(), (int)str.length(), (LPWSTR)wstr.c_str(), (int)wstr.length());

	return wstr;
}

static std::string WStringToString(const std::wstring& wstr)
{
	std::string str(wstr.length(), ' ');

	//std::copy(wstr.begin(), wstr.end(), str.begin());
	WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wstr.c_str(), (int)wstr.length(), (LPSTR)str.c_str(), (int)str.length(), NULL, NULL);

	return str;
}
